package com.hurl.waguji.base;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CollectionUtils {
	public static Map<String,Object> list2Map(List<Object> list, List<String> keyList){
		if(list==null || keyList==null || list.size()!=keyList.size())
			return null;
		
		Map<String,Object> map = new HashMap<String,Object>(keyList.size());
		
		for(int i=0;i<keyList.size();i++){
			map.put(keyList.get(i), list.get(i));
		}
		return map;
	}

	public static Map<String,Object> array2Map(Object[] list, List<String> keyList){
		if(list==null || keyList==null || list.length!=keyList.size())
			return null;
		
		Map<String,Object> map = new HashMap<String,Object>(keyList.size());
		
		for(int i=0;i<keyList.size();i++){
			map.put(keyList.get(i), list[i]);
		}
		return map;
	}
}
